﻿#region Vương văn hùng
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;

using DataAccess;
using Entities;
using Common;

namespace BusinessLogic
{
    static class Update
    {
        public static int Update_DuNo(string HanhDong, string MaUpdate,string DuNo)
        {
            int k = 0;
            try
            {
                SqlConnection cn = DataAccess.Connection.OpenConnection();
                SqlCommand cmd = new SqlCommand("exec sp_Update_DuNo @HanhDong,@MaUpdate,@DuNo", cn);
                cmd.Parameters.Add("HanhDong", SqlDbType.NVarChar).Value = HanhDong;
                cmd.Parameters.Add("MaUpdate", SqlDbType.VarChar).Value = MaUpdate;
                cmd.Parameters.Add("DuNo", SqlDbType.Float).Value = DuNo;
                k = cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                DataAccess.Connection.CloseConnection();
            }
            catch (Exception)
            {
                k= 0;
            }
            return k;
        }
        public static int Update_SoLuongConLai(string HanhDong,string MaHoaDon,string MaHangHoa,string SoLuongConLai)
        {
            try
            {
                SqlConnection cn = DataAccess.Connection.OpenConnection();
                SqlCommand cmd = new SqlCommand("exec sp_Update_SoLuongConLai HanhDong,MaHoaDon,MaHangHoa,SoLuongConLai", cn);
                cmd.Parameters.Add("HanhDong", SqlDbType.NVarChar).Value = HanhDong;
                cmd.Parameters.Add("MaHoaDon", SqlDbType.VarChar).Value = MaHoaDon;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.Float).Value = MaHangHoa;
                cmd.Parameters.Add("SoLuongConLai", SqlDbType.Float).Value = SoLuongConLai;
                return cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                DataAccess.Connection.CloseConnection();
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public static int Update_TrangThaiDonDatHang(string HanhDong, string MaDonDatHang, string TrangThai)
        {
            int k = 0;
            try
            {
                SqlConnection cn = DataAccess.Connection.OpenConnection();
                SqlCommand cmd = new SqlCommand("exec sp_Update_TrangThaiDonDatHang @HanhDong,@MaDonDatHang,@TrangThai", cn);
                cmd.Parameters.Add("HanhDong", SqlDbType.NVarChar).Value = HanhDong;
                cmd.Parameters.Add("MaDonDatHang", SqlDbType.VarChar).Value = MaDonDatHang;
                cmd.Parameters.Add("TrangThai", SqlDbType.NVarChar).Value = TrangThai;
                k= cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                DataAccess.Connection.CloseConnection();
            }
            catch (Exception)
            {
                k = 0;
            }
            return k;
        }
    }
}
#endregion
